package com.qf.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.qf.pojo.respVo.BaseResp;
import com.qf.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 陌人不故
 * @Date: 2022/10/26/22:12
 */
@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    CourseService courseService;

    @RequestMapping("/findCourseByClassify")
    @HystrixCommand(fallbackMethod ="findCourseByClassifyFallBack")
    public BaseResp findCourseByClassify(@RequestParam("id") Integer id,
                                         @RequestParam("page") Integer page,
                                         @RequestParam("size") Integer size){
        return courseService.findCourseByClassify(id, page, size);
    }


    public BaseResp findCourseByClassifyFallBack(@RequestParam("id") Integer id,
                                         @RequestParam("page") Integer page,
                                         @RequestParam("size") Integer size){
        return BaseResp.FAIL("课程服务出现异常!");
    }


    @RequestMapping("/findCourseDetailById/{id}")
    public BaseResp findCourseDetailById(@PathVariable("id") Integer id){
        return courseService.findCourseDetailById(id);
    }


}
